package com.fjh.springboot_01.mapper;

import com.fjh.springboot_01.pojo.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    
    @Insert("INSERT INTO comment (lesson_id, user_id, content, create_time, username, avatar) " +
            "VALUES (#{lessonId}, #{userId}, #{content}, #{createTime}, #{username}, #{avatar})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Comment comment);
    
    @Select("SELECT * FROM comment WHERE lesson_id = #{lessonId} ORDER BY create_time DESC")
    List<Comment> findByLessonId(Integer lessonId);
    
    @Delete("DELETE FROM comment WHERE id = #{id}")
    int deleteById(Integer id);
} 